Try using .loc[row_indexer,col_indexer] = value instead

23

import pandas as pd
pd.options.mode.chained_assignment = None  # default='warn'
# This will stop showing this warning 
# Alternatively you can use .loc as suggested by the message
import pandas as pd
pd.options.mode.chained_assignment = None  # default='warn'
new_df = df.loc[df.col1>2].copy()
new_df.loc[2, 'new_column'] = 100

Comments

Submit
0 Comments